home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / cstwnd / ncbutton.h < prev    next >
C/C++ Source or Header  |  1993-12-29  |  4KB  |  134 lines

  1. #ifndef _NCBUTTON_H_
  2. #define _NCBUTTON_H_
  3.  
  4. #ifndef __OWL_H
  5. #include <owl.h>
  6. #endif
  7.  
  8. _CLASSDEF(TNCButton)
  9. class _EXPORT TNCButton
  10. {
  11. public:
  12.     RECT    Window;
  13.     int    Id;
  14.     HWND    Parent;
  15.     int    Pos;
  16.    char    MaintainRB;    //Right or Bottom Position 
  17.  
  18.     TNCButton(HWND AParent, RECT& AWindow, int AnId);
  19.     virtual ~TNCButton();
  20.  
  21.     virtual void SetRight(int APos)
  22.         {    Pos = APos; MaintainRB = TRUE; };
  23.     virtual void DrawUp(HDC ToDC);
  24.     virtual void DrawDown(HDC ToDC);
  25.    virtual void Clicked(void);
  26.     virtual void PreClicked(void) {};
  27. protected:
  28.     int Width, Height, Left, Top;
  29.     virtual LPSTR GetClassName(void)
  30.        { return (LPSTR)"NCBUTTON"; };
  31. };
  32.  
  33. _CLASSDEF(TNCBitButton)
  34. class _EXPORT TNCBitButton : public TNCButton
  35. {
  36.     HBITMAP Up, Down;
  37.     BITMAP    BitObj;
  38. public:
  39.     TNCBitButton(HWND AParent, RECT& AWindow, int AnId,
  40.         HINSTANCE Inst, LPSTR BitUp, LPSTR BitDown);
  41.     ~TNCBitButton();
  42.  
  43.     virtual void DrawUp(HDC ToDC);
  44.     virtual void DrawDown(HDC ToDC);
  45. protected:
  46.     virtual LPSTR GetClassName(void)
  47.        { return (LPSTR)"NCBITBUTTON"; };
  48. };
  49.  
  50. /*******************************************************************
  51. I have no idea why I export it, everything expands inline.
  52. *******************************************************************/
  53. _CLASSDEF(TNCSystemButton)
  54. class _EXPORT TNCSystemButton : public TNCBitButton
  55. {
  56. public:
  57.     TNCSystemButton(HWND AParent, RECT& AWindow, int Type,
  58.         HINSTANCE Inst, LPSTR BitUp, LPSTR BitDown)
  59.         : TNCBitButton(AParent, AWindow, Type, Inst,
  60.             BitUp, BitDown)
  61.         { };
  62.     ~TNCSystemButton();
  63.     virtual void Clicked(void)
  64.         { PostMessage(Parent, WM_SYSCOMMAND, Id, 0l); };
  65. protected:
  66.     virtual LPSTR GetClassName(void)
  67.         { return (LPSTR)"NCSYSTEMBUTTON"; }; 
  68. };
  69.  
  70. _CLASSDEF(TNCCharButton)
  71. class _EXPORT TNCCharButton : public TNCButton
  72. {
  73.     HBITMAP    BitUp, BitDown;
  74.     HINSTANCE    Inst;
  75.    char* Char;
  76. public:
  77.     TNCCharButton(HWND AParent, RECT& AWindow, int AnId,
  78.         HINSTANCE AnInst, char* AChar);
  79.     ~TNCCharButton();
  80.  
  81.     void SetChar(char* AChar);
  82.     virtual void DrawUp(HDC ToDC);
  83.     virtual void DrawDown(HDC ToDC);
  84. protected:
  85.     virtual LPSTR GetClassName(void)
  86.         { return (LPSTR)"NCCHARBUTTON"; };
  87. };
  88.  
  89. _CLASSDEF(TNCRadioButton)
  90. class _EXPORT TNCRadioButton : public TNCButton
  91. {
  92.     HBITMAP    BitMask, BitOn, BitOff;
  93.     HINSTANCE Inst;
  94.     char    Changeable, State;
  95.    BITMAP    BitObj;
  96. public:
  97.     TNCRadioButton(HWND AParent, RECT& AWindow, int AnId,
  98.         HINSTANCE AnInst, LPSTR On, LPSTR Off, char Change,
  99.         char IState);
  100.     ~TNCRadioButton();
  101.  
  102.     char GetState(void);
  103.     char SetState(char NState);
  104.     virtual void DrawUp(HDC ToDC);
  105.     virtual void DrawDown(HDC ToDC);
  106.     virtual void Clicked(void);
  107.     virtual void PreClicked(void);
  108. protected:
  109.     virtual LPSTR GetClassName(void)
  110.         { return (LPSTR)"NCRADIOBUTTON"; };
  111. };
  112.  
  113. //Some defines that make using the above classes a
  114. //little easier
  115.  
  116. /*******************************************************************
  117. Position from the left of a standard top title bar.
  118. *******************************************************************/
  119. #define AreaFromTopLeft(rct, pos) \
  120.     {    rct.left = TitleRect.left + BitWidth * (pos);\
  121.         rct.top = TitleRect.top;\
  122.         rct.right = TitleRect.left + BitWidth * ((pos)+1);\
  123.         rct.bottom = TitleRect.top + BitHeight - 1; };
  124.  
  125. /*******************************************************************
  126. Position from the right of a standard top title bar.
  127. *******************************************************************/
  128. #define AreaFromTopRight(rct, pos) \
  129.     {    rct.left = TitleRect.right - BitWidth * ((pos)+1);\
  130.         rct.top = TitleRect.top;\
  131.         rct.right = TitleRect.right - BitWidth * (pos);\
  132.         rct.bottom = TitleRect.top + BitHeight-1; };
  133.  
  134. #endif